package xmu.crms.dao;

import xmu.crms.entity.ClassInfo;
import xmu.crms.entity.Location;
import xmu.crms.entity.Seminar;
import xmu.crms.exception.*;

import java.math.BigInteger;
import java.util.List;

/**
 * @author hxr
 */

public interface ClassDao {

    /**
     * 根据班级id删除该班级所有选课记录.
     * @param classId
     * @return
     */
    Boolean deleteClassSelectionByClassId(BigInteger classId);

    /**
     * 根据课程名称和教师名称获取班级列表.
     * @param courseName
     * @param teacherName
     * @return
     * @throws UserNotFoundException
     * @throws CourseNotFoundException
     * @throws ClassesNotFoundException
     */
    List<ClassInfo> listClassByName(String courseName, String teacherName) throws
            UserNotFoundException,CourseNotFoundException,ClassesNotFoundException;

    /**
     * 根据课程id找到班级列表.
     * @param courseId
     * @return
     * @throws CourseNotFoundException
     */
    List<ClassInfo> findClassByCourseId(BigInteger courseId) throws
            CourseNotFoundException;

    /**
     * 根据班级id找到班级.
     * @param classId
     * @return
     * @throws ClassesNotFoundException
     */
    ClassInfo findClassByClassId(BigInteger classId) throws
            ClassesNotFoundException;

    /**
     * 根据班级id更新班级信息.
     * @param classId
     * @param newClass
     * @return
     * @throws ClassesNotFoundException
     */
    Boolean updateClassByClassId(BigInteger classId, ClassInfo newClass) throws
            ClassesNotFoundException;

    /**
     * 根据班级id删除班级.
     * @param classId
     * @return
     * @throws ClassesNotFoundException
     */
    Boolean deleteClassByClassId(BigInteger classId)
            throws ClassesNotFoundException;

    /**
     * 根据用户id和班级id新增选课记录.
     * @param userId
     * @param classId
     * @return
     * @throws UserNotFoundException
     * @throws ClassesNotFoundException
     */
    BigInteger insertCourseSelectionById(BigInteger userId, BigInteger classId) throws
            UserNotFoundException,ClassesNotFoundException;

    /**
     * 根据用户id和班级id删除选课记录.
     * @param userId
     * @param classId
     * @return
     * @throws UserNotFoundException
     * @throws ClassesNotFoundException
     */
    Boolean deleteCourseSelectionById(BigInteger userId, BigInteger classId) throws
            UserNotFoundException,ClassesNotFoundException;


    /**
     * 根据用户id和班级id找到课程id.
     * @param userId
     * @param classId
     * @return
     */
    BigInteger findCourseIdByUserIdAndClassId(BigInteger userId, BigInteger classId);


    /**
     * 根据班级id和课程id获取班级签到状态.
     * @param classId
     * @param seminarId
     * @return
     * @throws SeminarNotFoundException
     */
    Location getCallStatusById(BigInteger classId, BigInteger seminarId) throws SeminarNotFoundException;


    /**
     * 根据课程id新建班级.
     * @param courseId
     * @param classInfo
     * @return
     * @throws CourseNotFoundException
     */
    BigInteger insertClassById(BigInteger courseId, ClassInfo classInfo) throws
            CourseNotFoundException;

    /**
     * 根据课程id删除该课程下所有班级.
     * @param courseId
     * @throws CourseNotFoundException
     */
    void deleteClassByCourseId(BigInteger courseId) throws
            CourseNotFoundException;

    /**
     * 根据班级id删除评分规则.
     * @param classId
     * @throws ClassesNotFoundException
     */
    void deleteScoreRuleById(BigInteger classId) throws ClassesNotFoundException;

    /**
     * 根据班级id获取评分规则.
     * @param classId
     * @return
     * @throws ClassesNotFoundException
     */
    ClassInfo getScoreRule(BigInteger classId) throws ClassesNotFoundException;

    /**
     * 根据班级id新增评分规则.
     * @param classId
     * @param proportions
     * @return
     * @throws InvalidOperationException
     * @throws ClassesNotFoundException
     */
    BigInteger insertScoreRule(BigInteger classId, ClassInfo proportions)
            throws InvalidOperationException,ClassesNotFoundException;

    /**
     * 插入一条班级签到状态.
     * @param location
     * @return
     * @throws SeminarNotFoundException
     * @throws ClassesNotFoundException
     */
    BigInteger callInRollById(Location location)
            throws SeminarNotFoundException,ClassesNotFoundException;

    /**
     * 根据用户id列出班级.
     * @param userId
     * @return
     * @throws IllegalArgumentException
     * @throws ClassesNotFoundException
     */
    List<ClassInfo> listClassByUserId(BigInteger userId)
            throws IllegalArgumentException, ClassesNotFoundException;

    /**
     * 结束签到.
     * @param location
     * @throws SeminarNotFoundException
     * @throws ClassesNotFoundException
     */
    void endCallRollById(Location location)
            throws SeminarNotFoundException, ClassesNotFoundException;

    /**
     * 根据班级id删除该班级下所有选课记录.
     * @param classId
     * @throws ClassesNotFoundException
     */
    void deleteCoueseSelectionByClassId(BigInteger classId) throws ClassesNotFoundException;

    /**
     * 根据课程id列出该课程下所有班级.
     * @param courseId
     * @return
     */
    List<ClassInfo> listClassByCourseId(BigInteger courseId);
}
